@extends('admin.layout.layout', ['row' => @$page])

@section('title', @$page['title'])

@section('contain')

    <div class="portlet">
        <div class="portlet-title">
            <div class="caption">
                <span class="caption-subject font-green-sharp bold uppercase">{{ @$page['title'] }}</span>
            </div>
            <div class="actions">
                <div class="item">
                </div>
            </div>
        </div>

        <div>
            <form action="./" method="post" onsubmit="return checkVal(this)">
                @csrf
                @method('PUT')
                <div class="form-item form-s1">
                    <div class="form-label" required>{{ ts('ENGLISH') }}</div>
                    <div class="form-input">
                        <input type="text" class="form-control" name="english_value" value="{{ $data['english_value'] }}">
                    </div>
                </div>
                <div class="form-item form-s1">
                    <div class="form-label" required>{{ ts('CHINESET') }}</div>
                    <div class="form-input">
                        <input type="text" class="form-control" name="traditional_chiness_value" value="{{ $data['traditional_chiness_value'] }}">
                    </div>
                </div>
                <div class="form-item form-s1">
                    <div class="form-label" required>{{ ts('CHINESES') }}</div>
                    <div class="form-input">
                        <input type="text" class="form-control" name="simplified_chiness_value" value="{{ $data['simplified_chiness_value'] }}">
                    </div>
                </div>
                <div class="mt-4 mx-3">
                    <button class="btn btn-primary">{{ ts('UPDATE') }}</button>
                </div>
            </form>
        </div>

    </div>

@endsection

@section('script')
    <script>
        for (var i = 0; i < $('.portlet .flatpickr').length; i++) {
            var ele = $('.flatpickr').eq(i);
            ele.flatpickr({
                minDate: ele.data('min'),
                maxDate: ele.data('max'),
                "locale": "zh"
            })
        }
        function checkVal(ele) {
            var items = $(ele).find('.form-item');
            var state = true,
                msg = '';
            for (var i = 0; i < items.length; i++) {
                var e = items.eq(i);
                var v = e.find('.form-control').val();
                if (state && e.find('.form-label').attr('required')!=undefined && !(String(v).trim())) {
                    state = false;
                    msg = e.find('.form-label').text() + ' 不能为空！';
                    e.find('.form-control').focus();
                    toastr.error(msg);
                    return false;
                }
            }
            return state
        }
    </script>
@endsection
